﻿/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __0685A7E5_ED1F_46b0_8F45_21D4F1386AD8__
#define __0685A7E5_ED1F_46b0_8F45_21D4F1386AD8__

#include <cstdarg>
#include <cstdio>
#include "../macro/head.h"
#include "../release/head.h"

/////////////////////////////////////////////////////////////////////////////////////////
// 
namespace xos
{
    // 
    // crt interface
    // 
    class i_crt : public i_release
    {
    public:
        virtual ~i_crt(){}

    public:
        virtual const void * mem_find( const void * lpMainMem, int nMainLen, const void * lpSubMem, int nSubLen ) = 0;
        virtual int memmove( void * lpDst, const void * lpSrc, int nSize ) = 0;
		virtual int memcpy( void * lpDst, const void * lpSrc, int nSize ) = 0;
        virtual int memset( void * lpDst, int nValue, int nSize ) = 0;

        virtual const char * strrstr( const char * lpszStr, const char * lpszSubStr, bool bCaseSensitive ) = 0;
        virtual const char * strstr( const char * lpszStr, const char * lpszSubStr, bool bCaseSensitive ) = 0;

        virtual char * strrstr( char * lpszStr, const char * lpszSubStr, bool bCaseSensitive ) = 0;
        virtual char * strstr( char * lpszStr, const char * lpszSubStr, bool bCaseSensitive ) = 0;

        virtual const char * strrchr( const char * lpszStr, char c ) = 0;
        virtual const char * strchr( const char * lpszStr, char c ) = 0;

        virtual char * strrchr( char * lpszStr, char c ) = 0;
        virtual char * strchr( char * lpszStr, char c ) = 0;

        virtual int vsnprintf( char * lpszBuf, int nBufSize, const char * format, va_list argptr ) = 0;
        virtual int sprintf( char * buf, int nBufSize, const char * lpszFormat, ... ) = 0;
        virtual char * strptime( const char * buf, const char * fmt, struct tm * tm ) = 0;
        virtual int gets( char * lpszBuf, int nBufSize ) = 0;

        virtual double atof( const char * lpszStr ) = 0;
        virtual xos_i64 atoi64( const char * lpszStr ) = 0;
        virtual int atoi( const char * lpszStr ) = 0;
        virtual int atol( const char * lpszStr ) = 0;

        virtual int uppercase( const char * lpszSrc, char * lpszDst ) = 0;
        virtual int lowercase( const char * lpszSrc, char * lpszDst ) = 0;
        virtual int toupper( char c ) = 0;
        virtual int tolower( char c ) = 0;

        // nBufSize is total size of lpszDst buf.
        virtual char * strncpy( char * lpszDst, int nBufSize, const char * lpszSrc, int nLen ) = 0;
        virtual char * strcpy( char * lpszDst, int nBufSize, const char * lpszSrc ) = 0;
        virtual char * strcat( char * lpszDst, int nBufSize, const char * lpszSrc ) = 0;
        virtual int strlen( const char * lpszStr ) = 0;

        virtual int stricmp( const char * lpszStr1, const char * lpszStr2 ) = 0;
        virtual int strcmp( const char * lpszStr1, const char * lpszStr2 ) = 0;

        virtual int assert_valid( bool bAssert ) = 0;

        // 
        // if uSeed is 0, sys will add seed
        // 
        virtual int srand( xos::xos_u32 uSeed ) = 0;
        virtual int rand( int nMax ) = 0;
    };
}

#endif // __0685A7E5_ED1F_46b0_8F45_21D4F1386AD8__
